<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Js动画与Velocity.js</title>
  <script src="vue.js"></script>
  <script src="velocity.min.js"></script>
  <link rel="stylesheet" href="css/animate.css">
  <style>
  </style>
</head>
<body>
<div id="app">
  <transition
    name="fade"
    @before-enter="handleBeforeEnter"
    @enter="handleEnter"
    @after-enter="handleAfterEnter"
    @before-leave="handleBeforeLeave"
    @leave="handleLeave"
    @after-leave="handleAfterLeave"
  >
    <div v-show="show">hello world</div>
  </transition>
  <button @click="handelBtnClick">change</button>
</div>
<script>
  var vm=new Vue({
    el:"#app",
    data:{
      show:true
    },
    methods:{
      handelBtnClick:function(){
        this.show=!this.show
      },
      handleBeforeEnter:function(el){
        el.style.opacity=0;
      },
      handleEnter:function(el,done){
        Velocity(el,{
          opacity:1
        },{
          duration:2000,
          complete:done
        })
      },
      handleAfterEnter:function(el){
        console.log("show")
      },
      handleBeforeLeave:function(el){
        el.style.opacity=1;
      },
      handleLeave:function(el,done){
        Velocity(el,{
          opacity:0
        },{
          duration:2000,
          complete:done
        })
      },
      handleAfterLeave:function(el){
         console.log("hide")
      }
    }
  })
</script>
</body>
</html>
